<?php
namespace BP\En;
class SQLCash {
	public $EnName;	// String
	public $Insert;	// String
	public $Update;	// String
	public $Delete;	// String
	public $Select;	// String
	protected $_UpdateSQLs;	// Hashtable
	private function __init() { // default class members
		$this->EnName = NULL;
		$this->Insert = NULL;
		$this->Update = NULL;
		$this->Delete = NULL;
		$this->Select = NULL;
	}
	public static function constructor__ () 
	{
		$me = new self();
		$me->__init();
		return $me;
	}
	public static function constructor__Entity ($en) // [Entity en]
	{
		$me = new self();
		$me->__init();
		$me->EnName = $en;
		$me->Insert = SqlBuilder::InsertForPara($en);
		$me->Update = SqlBuilder::UpdateForPara($en, NULL);
		$me->Delete = SqlBuilder::DeleteForPara($en);
		$me->Select = SqlBuilder::RetrieveForPara($en);
		return $me;
	}
	public function GetUpdateSQL ($en, $keys) // [Entity en, String[] keys]
	{
		if (($keys == NULL))
		{
			return $this->Update;
		}
		$mykey = "";
		foreach ($keys as $k) 		{
			$mykey += $k;
		}
		$tempVar = $this->getUpdateSQLs()->get($mykey);
		$sql = ( ($tempVar instanceof String) ? $tempVar : NULL );
		if (($sql . NULL))
		{
			$this->getUpdateSQLs()->put($mykey, SqlBuilder::UpdateForPara($en, $keys));
		}
		$tempVar2 = $this->getUpdateSQLs()->get($mykey);
		$sql = ( ($tempVar2 instanceof String) ? $tempVar2 : NULL );
		if (($sql . NULL))
		{
			throw new \RuntimeException("@error");
		}
		return $sql;
	}
	public function getUpdateSQLs () 
	{
		if (($this->_UpdateSQLs == NULL))
		{
			$this->_UpdateSQLs = new Hashtable();
		}
		return $this->_UpdateSQLs;
	}
}
?>
